home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
rjcom.exe
/
COM.TXT
< prev
next >
Wrap
Text File
|
1991-12-14
|
59KB
|
2,043 lines
COM.LIB communications
The functions described in this document allow a C program to set
up and control communications that will take place through the
serial ports. The routines are found in the library COM_S.LIB
for small model or COM_L for the large C model. The initializa-
tion function sets up an ISR that handles communications. The
ISR takes the place of INT-14 and supports up to four serial
interfaces. COM.LIB supports both IRQ-3 and IRQ-4 for transmit
and receive and also supports other enhanced commands for the COM
ports. In addition to this file, INT_14.H is a header file that
must be included. It contains the necessary definitions for
communication port data transfers done with this library of
routines.
INT_14.H specify four typedefs that will be used extensively
throughout this document. They are as follows:
typedef unsigned char uc;
typedef unsigned int ui;
typedef unsigned long ul;
typedef unsigned short us;
These storage classes have been defined in this manner to facili-
tate casting operations and to eliminate keystrokes in normal
declarations.
It should be noted that the variable cn, used extensively in the
following definitions to symbolize the com_number, is of the
following format:
( COM1 = 0, COM2 = 1, COM3 = 2, COM4 = 3, etc... )
There are several shorthand notations used in this document.
They are listed here:
-> points to
LSBit least significant bit
MSBit most significant bit
LSByte least significant byte
MSByte most significant byte
There are several error codes that may be returned by functions
described in this document. They are listed below:
NO_ERROR 0
ILLEGAL_COM_PORT -1
INPUT_QUEUE_EMPTY -2
OUTPUT_QUEUE_FULL -3
ERROR_BAUD_RATE -4
ERR_HSK_IN_PLACE -6
ERR_BAD_DATA -7
ERR_CARRIER_DROPPED -8
Global Variables
--------------------------------------------------------
There are a few global variables that may be viewed or altered by
the application. Because the serial ports are interrupt driven,
any accesses made with a variable that is above 16-bits should be
made only while interrupts are disabled.
us _Com_Cprint_Output
This is a bit field that determines the device that the bytes
that are sent out through cprint(). If bit 0 is set, characters
will be sent to the display console. If bit 1 is set, the char-
acters are sent to the COM number held in _Cprint_Cn. Any combi-
nation of these bits may be set or cleared.
us _Com_Error_Count[]
This is an array that contains the number of error conditions
that have happened for each of the COM ports.
ul _Com_Total_In
This contains the total number of bytes that have been received
from all the COM ports combined.
ul _Com_Total_Out
This contains the total number of bytes that have been sent out
all the COM ports combined.
us Com_Xfer_Timeout
Default number of system ticks between sequential transmitted or
received characters before modem style functions (ie cprint())
return a timeout error.
us _Cprint_Cn
This is the COM number that cprint() uses to communicate through.
us _Xon_Percent
This is the percentage of the input buffer that can be full
before the ISR sends an XON to the remote.
Global Variables (cont.)
--------------------------------------------------------
us _Xoff_Percent
This is the percentage of the input buffer that can be full when
the ISR sends an XOFF to the remote.
com_assert_dtr
--------------------------------------------------------
Summary
#include <int_14.h>
short com_assert_dtr( cn );
us cn; The COM port to initialize
Description
This function asserts the data terminal ready signal ( DTR )
on the specified COM port cn. Asserting this signal usually
informs a modem that the computer is powered up and ready
for communications.
Return Value
The function returns a zero if completed, else the appropri-
ate error code is returned
See Also
com_drop_dtr
com_assert_rts
--------------------------------------------------------
Summary
#include <int_14.h>
short com_assert_rts( cn );
us cn; The COM port to initialize
Description
This function asserts the request to send ( RTS ) on the
specified COM port cn. Asserting this signal may inform the
modem or other system that you want to send data. In hard-
ware handshaking, asserting this signal is used to tell the
sending system to send data.
Return Value
The function returns a zero if completed, else the appropri-
ate error code is returned
See Also
com_drop_dtr
com_clear_input
----------------------------------------------------------------
Summary
#include <int_14.h>
short com_clear_input( cn );
us cn; The COM port to initialize
Description
This function clears the input buffer that is associated
with the COM port cn. The input buffer holds the bytes that
are received by the port but have not yet been retrieved by
the input routines. Clearing this buffer will destroy any
data that has been received and not retrieved.
Return Value
This routine returns a zero if all went OK, else a comple-
tion code will be returned explaining the error.
See Also
com_clear_output
com_clear_output
----------------------------------------------------------------
Summary
#include <int_14.h>
short com_clear_output( cn );
us cn; The COM port to initialize
Description
This function clears